home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com
- Newsgroups: comp.lang.c++
- Subject: Re: How do I combin C and C++ code into a simple VC++ project?
- Date: 26 Jan 1996 22:32:39 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4ebkq7$j44@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe12.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 26, 1996 17:00:02 in article <How do I combin C and C++ code into a
- simple VC++ project?>, 'howard@vvm.com (Jon Howard)' wrote:
-
-
- >I have a project where the majority of the code is C, but I want to
- >call some functions written in C++ (that are sitting in a different
- >file). They all compile great, but at link time the compiler can't
- >seem to find the C++ function. Is this type of mixing not allowed? I'm
- >using Visual C++ 1.5 on Win 3.1.
- >
- Yes. Read about extern "C" declaration. Example:
-
- File cppfuncs.h (which is the header file include in both C and C++
- source modules):
-
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- int CppFunc(int foo, char * bar);
- [more C++ function declarations]
-
- #if defined(__cplusplus)
- }
- #endif
-
- BTW, do not attempt to export class member functions this
- way -- well, I suppose you could export static members, but
- that's beyod the scope of this msg.
-
- Another BTW: Note that __cplusplus has two underscores.
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-